<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@include file="../public/header.jsp" %>

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/jquery-ui-1.8.17.custom.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/lib/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/lib/jquery-ui-i18n.js"></script>

<img src="<%=request.getContextPath()+"/resources/images/editweight_logo.jpg"%>" class="logo">
<div class="form-wrapper editweight-form-wrapper"> 
	<div class="form-header">
		<div class="form-title">
			<fmt:message key="label.editweight.title"></fmt:message>
		</div> 
	</div>
	<div class="form-body">
		<form:form id="editWeightFormId" method="post" action="/private/weight/saveWeight.action" modelAttribute="weightForm">
			<form:hidden path="id"/>
			<form:hidden path="enabled"/>
			<form:hidden path="modelId"/>
			<label id="dateFieldLabelId" for="dateFieldId" class="form-label editweight-form-field-label">
				<fmt:message key="label.date"></fmt:message>:
			</label> 
			<form:input path="date" id="dateFieldId" cssClass="form-field editweight-form-field editweight-form-field-readonly"/>
    		<label id="weightFieldLabelId" for="weightFieldId" class="form-label editweight-form-field-label">
    			<fmt:message key="label.weight"></fmt:message>:
    		</label> 
    		<form:input  path="weight" id="weightFieldId" cssClass="form-field editweight-form-field"/>
    		<script type="text/javascript">var fill = false;</script>
    		<c:if test="${not empty weightForm.eatings}">
    			<div class="eatings-wrapper">
    			<c:forEach var="eating" items="${weightForm.eatings}">
					<a href="<%=request.getContextPath()+"/private/eating/initEditEating.action?id="%>${eating.id}&amp;weightId=${weightForm.id}" class="eating-item">${eating.time}&nbsp;${eating.eatingType.displayName}</a>
				</c:forEach>
				</div> 
			</c:if>
			<div class="form-button-wrapper2 trenning-wrapper">
    			<form:checkbox  path="trenning" id="trenningFieldId" cssClass="checkbox"/>
    			<label for="trenningFieldId" class="label-check-select">
    				<fmt:message key="label.trenning"></fmt:message> 
    			</label>
    		</div>
    		<div class="registration-form-button-wrapper">
    			<a href="<%=request.getContextPath()+"/private/model/main.action"%>" class="form-button form-button-back-to-login">
    				<fmt:message key="button.back"></fmt:message>
    			</a>
    			<input type="button" id="clearButtonId" value=<fmt:message key="button.clear"></fmt:message> class="form-button form-button-registration-clear" /> 
    			<input type="button" id="saveWeightButtonId" value=<fmt:message key="button.save"></fmt:message> class="form-button form-button-register"/>
    		</div>
         </form:form>
	</div>
	<div class="form-footer">
	</div>
</div>

<div class="form-wrapper registration-form-error-wrapper">
	<div class="form-header">
		<div class="form-title form-error-title">
			<fmt:message key="label.error"></fmt:message>
		</div>
	</div>
	<ul id="errorsListId" class="form-error-text">
		<c:forEach var="err" items="${weightForm.errors}">
			<li>${err}</li>
		</c:forEach>
	</ul>		
	<div class="form-footer"></div>
</div>

<c:if test="${not empty weightForm.errors}">
	<script type="text/javascript">
		$('.registration-form-error-wrapper').css('display', 'inline-block');
	</script>
</c:if>

<script type="text/javascript">
	var messages = new Array();
	messages['message.error.field'] = '<fmt:message key="message.error.field"/>';
	messages['message.error.empty'] = '<fmt:message key="message.error.empty"/>';
	messages['message.error.field.length'] = '<fmt:message key="message.error.field.length"/>';
	messages['message.error.length.greater'] = '<fmt:message key="message.error.length.greater"/>';
	messages['message.error.passwords.not.equal'] = '<fmt:message key="message.error.passwords.not.equal"/>';
	messages['message.error.field.contain.incorrect.symbols'] = '<fmt:message key="message.error.field.contain.incorrect.symbols"/>';
	messages['message.error.field.invalid.format'] = '<fmt:message key="message.error.field.invalid.format"/>';
</script>

<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/app/weight.js"></script>
<%@include file="../public/footer.jsp" %>	